package com.qf.pojo;

import java.util.List;

/**
 * @author 沐辰
 * @version v1.0
 * @description:
 * @company qf
 */
public class Page<T> {
    //当前页面
    private int page;
    //每一页的条数
    private int size;
    //偏移值
    private int offset;
    //总条数
    private int countSize;
    //总页数
    private int countPage;
    //首页
    private int homePage;
    //尾页
    private int lastPage;
    //每一页的信息
    private List<T> pageMsg;

    public Page() {
    }

    public Page(int page, int size) {
        this.page = page;
        this.size = size;
        offset = (page - 1) * size;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public int getOffset() {
        return offset;
    }

    public void setOffset(int offset) {
        this.offset = offset;
    }

    public int getCountSize() {
        return countSize;
    }

    public void setCountSize(int countSize) {
        this.countSize = countSize;
        countPage = countSize % size == 0 ? countSize / size : countSize / size + 1;
    }

    public int getCountPage() {
        return countPage;
    }

    public void setCountPage(int countPage) {
        this.countPage = countPage;
    }

    public int getHomePage() {
        return homePage;
    }

    public void setHomePage(int homePage) {
        this.homePage = homePage;
    }

    public int getLastPage() {
        return lastPage;
    }

    public void setLastPage(int lastPage) {
        this.lastPage = lastPage;
    }

    public List<T> getPageMsg() {
        return pageMsg;
    }

    public void setPageMsg(List<T> pageMsg) {
        this.pageMsg = pageMsg;
    }

    @Override
    public String toString() {
        return "Page{" +
                "page=" + page +
                ", size=" + size +
                ", offset=" + offset +
                ", countSize=" + countSize +
                ", countPage=" + countPage +
                ", homePage=" + homePage +
                ", lastPage=" + lastPage +
                ", pageMsg=" + pageMsg +
                '}';
    }
}
